package com.yixun.qfbao.response.commission;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;

import com.yixun.qfbao.xf.model.dto.CustomerPremisesDto;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author zilong.liu
 * @date 2020-9-11
 */
@Data
public class CommissionResDto {

	@ApiModelProperty(value = "楼盘名称")
	private String premisesName;
	
	@ApiModelProperty(value = "员工姓名")
	private String staffName;
	
	@ApiModelProperty(value = "报备时间")
	private String reportTime;
	
	@ApiModelProperty(value = "已结金额")
	private BigDecimal hasBalance;
	
	@ApiModelProperty(value = "待结金额")
	private BigDecimal hasNoBalance;

	public CommissionResDto() {}
	
	public CommissionResDto(CustomerPremisesDto customerPremisesDto) {
		this.premisesName = customerPremisesDto.getPremisesName();
		this.staffName = customerPremisesDto.getName();
		this.reportTime = new SimpleDateFormat("yyyy.MM.dd HH:mm").format(customerPremisesDto.getCreateTime());
		BigDecimal pendingCommission = customerPremisesDto.getAgentPendingCommission() == null? new BigDecimal(0): customerPremisesDto.getAgentPendingCommission();
		BigDecimal receivedCommission = customerPremisesDto.getAgentReceivedCommission() == null? new BigDecimal(0): customerPremisesDto.getAgentReceivedCommission();
		this.hasNoBalance = pendingCommission.divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP);
		this.hasBalance = receivedCommission.divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP);
	}
	
}
